package com.haoting.mamba.player.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.haoting.mamba.player.entity.PlayerBasicdateEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.haoting.mamba.player.entity.PlayerAdvancedEntity;
import com.haoting.mamba.player.service.PlayerAdvancedService;
import com.haoting.common.utils.PageUtils;
import com.haoting.common.utils.R;



/**
 * 
 *
 * @author tanghao
 * @email 767417609@qq.com
 * @date 2021-03-14 20:47:39
 */
@RestController
@RequestMapping("player/playeradvanced")
public class PlayerAdvancedController {
    @Autowired
    private PlayerAdvancedService playerAdvancedService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = playerAdvancedService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		PlayerAdvancedEntity playerAdvanced = playerAdvancedService.getById(id);

        return R.ok().put("playerAdvanced", playerAdvanced);
    }

    @PostMapping("/infoByPlayerId/{id}")
    public R infoByPlayerId(@PathVariable("id") String id){
        QueryWrapper<PlayerAdvancedEntity> wrapper =new QueryWrapper<>();
        wrapper.eq("player_id",id)
        .eq("stage",0);
        PlayerAdvancedEntity one = playerAdvancedService.getOne(wrapper);
        return R.ok().put("playerAdvanced", one);
    }

    @GetMapping("/getPlayerId/{id}")
    public R getPlayerId(@PathVariable("id") String id){
        PlayerAdvancedEntity playerAdvancedEntity = playerAdvancedService.getById(id);
        return R.ok().put("playerId",playerAdvancedEntity.getPlayerId());
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PlayerAdvancedEntity playerAdvanced){
		playerAdvancedService.save(playerAdvanced);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PlayerAdvancedEntity playerAdvanced){
		playerAdvancedService.updateById(playerAdvanced);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		playerAdvancedService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
